package com.yundin.config;

import com.yundin.properties.AliOssProperties;
import com.yundin.properties.QiniuOssProperties;
import com.yundin.utils.AliOssUtil;
import com.yundin.utils.QiniuOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类，用于创建AliOssUtil对象
 */
@Configuration
@Slf4j
public class OssConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public QiniuOssUtil qiniuOssUtil(QiniuOssProperties qiniuOssProperties){
        log.info("开始创建七牛云文件上传工具类对象：{}",qiniuOssProperties);
        return new QiniuOssUtil(qiniuOssProperties.getEndpoint(),
                qiniuOssProperties.getAccessKeyId(),
                qiniuOssProperties.getAccessKeySecret(),
                qiniuOssProperties.getBucketName());
    }
}